<template>
  <div>
    <catch-table :form-create="formCreate" v-bind="table"/>

    <!-- 用户信息 -->
    <el-dialog title="用户信息预览" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">

      <el-descriptions v-if="e" border>
        <el-descriptions-item label="公司类型">{{ e.company_type_name }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==3 || e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5 || e.company_type==7" label="公司名">{{ e.company_name }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==8" label="协会全称">{{ e.company_name }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==6" label="队伍名">{{ e.team_name }}</el-descriptions-item>
        <el-descriptions-item label="营业执照">
          <el-image style="width: 100px; height: 100px" :src="e.company_license_show" :preview-src-list="[e.company_license_show]"></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="详细地址">{{ e.city_name }}{{ e.city_address }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==3 || e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5 || e.company_type==7" label="实际开始经营时间">{{ e.run_date }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==8" label="主管单位">{{ e.zhu_guan_company }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==8" label="成立时间">{{ e.register_date }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==8" label="会员单位数量">{{ e.user_num }}</el-descriptions-item>

        <el-descriptions-item v-if="e.company_type==3" label="生产产品">{{ e.make_goods }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==3 || e.company_type==7" label="经销产品">{{ e.sale_goods }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==7" label="主要客户">{{ e.main_customer }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==8" label="主要业务">{{ e.main_ye_wu }}</el-descriptions-item>

        <el-descriptions-item v-if="e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5" label="主营业务">{{ e.main_ye_wu }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5" label="拥有资质">{{ e.zi_zhi }}</el-descriptions-item>

        <el-descriptions-item v-if="e.company_type==3 || e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5" label="三大电网">{{ e.dian_name }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==3 || e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5" label="五大六小">{{ e.ji_tuan_name }}</el-descriptions-item>
        <el-descriptions-item v-if="e.company_type==3 || e.company_type==2 || e.company_type==6 || e.company_type==4 || e.company_type==5 || e.company_type==7" label="外贸">{{ e.wai_mao_name }}</el-descriptions-item>

        <el-descriptions-item label="负责人姓名">{{ e.person_realname }}</el-descriptions-item>
        <el-descriptions-item label="负责人职务">{{ e.person_duty }}</el-descriptions-item>
        <el-descriptions-item label="负责人手机号">{{ e.person_mobile }}</el-descriptions-item>
        <el-descriptions-item label="联系人姓名">{{ e.linkman_realname }}</el-descriptions-item>
        <el-descriptions-item label="联系人职务">{{ e.linkman_duty }}</el-descriptions-item>
        <el-descriptions-item label="联系人手机号">{{ e.linkman_mobile }}</el-descriptions-item>
        <el-descriptions-item label="联系人邮箱">{{ e.linkman_email }}</el-descriptions-item>

        <el-descriptions-item label="申请时间">{{ e.apply_time }}</el-descriptions-item>
        <el-descriptions-item label="审核状态">{{ e.company_status_name }}</el-descriptions-item>
      </el-descriptions>

      <div style="margin: 0 auto;">
        <div style="margin: 40px auto;">
          <el-button v-if="e.company_status == 2 " type="primary" @click="tgsh(e)">通过</el-button>
          <el-button v-if="e.company_status == 2 " type="primary"
                     @click="company_status_noteshow = !company_status_noteshow"
          >拒绝
          </el-button>
        </div>
      </div>

      <div v-show="company_status_noteshow == true" style="margin: 30px;width: 550px;">
        <el-input type="textarea" :rows="6" placeholder="请输入未通过审核的详细理由:" v-model="company_status_note">
        </el-input>
        <div style="margin-top: 30px;">
          <el-button v-if="e.company_status == 2 " type="primary" @click="jujue(e)">提交拒绝</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 审核记录 -->
    <el-dialog :visible.sync="shinfo" width="30%">
      <!--  <el-descriptions class="margin-top"  :column="3" size="small" border v-for="(item,index) in shlist" :key="index">

            <el-descriptions-item label="审核时间">{{item.created_at}}</el-descriptions-item>
            <el-descriptions-item label="审核状态">{{item.company_status_name}}</el-descriptions-item>
            <el-descriptions-item label="审核信息">{{item.company_status_note}}</el-descriptions-item>

          </el-descriptions> -->

      <el-table :data="shlist" style="width: 100%">
        <el-table-column prop="company_status_name" label="审核状态" width="180"></el-table-column>
        <el-table-column prop="created_at" label="审核时间" width="180"></el-table-column>
        <el-table-column prop="company_status_note" label="审核信息"></el-table-column>
      </el-table>

    </el-dialog>


    <el-dialog :visible.sync="address" width="60%">
      <baidu-map :center="location" :zoom="zoom" :scroll-wheel-zoom="wheel" @ready="handler"
                 style="width: 100%; height: 450px" :mapClick="false" :mapType="mapType" id="map" @mouseout="mouseout"
                 @mouseover="mouseover"
      >
      </baidu-map>

    </el-dialog>
  </div>

</template>

<script>
import renderTable from '@/views/render-table-form'

import {
  BaiduMap
} from 'vue-baidu-map'

export default {
  mixins: [renderTable],
  data() {
    return {
      company_status_note: '',
      company_status_noteshow: false,
      tableFrom: '',
      dialogVisible: false,
      e: {
        company_status: 0
      },
      shinfo: false,
      shlist: [],
      address: false,

      location: {
        lng: 36,
        lat: 117
      },
      zoom: 11,
      wheel: true,
      mapType: '',
      BMap: null,
      map: null

    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
      this.company_status_noteshow = false
      this.company_status_note = ''
    },
    tongguoshenhe(e) {

      this.dialogVisible = true
      this.e = e

    },

    viewaddress(e) {
      console.log(e)
      this.address = true
    },

    tginfo(e) {
      console.log(e)
    },
    shlog(e) {
      this.shinfo = true
      this.$http({
        url: '/UserCompany/auditLog?user_company_id=' + e.id,
        method: 'POST'
      }).then(r => {
        this.shlist = r.data
        console.log(this.shlist)
      })
    },

    tgsh(e) {
      this.$confirm('确定审核通过吗', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/userCompany/audit',
          method: 'POST',

          data: {
            'id': e.id,
            'company_status': 3
          }

        }).then(res => {
          this.$message({
            type: 'success',
            message: res.message
          })
          this.dialogVisible = false
          this.$refs[this.table.ref].getList()
        })
      })
    },

    jujue(e) {
      this.$confirm('确定拒绝申请吗', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/userCompany/audit',
          method: 'POST',

          data: {
            'id': e.id,
            'company_status': 4,
            'company_status_note': this.company_status_note
          }

        }).then(res => {
          this.$message({
            type: 'success',
            message: res.message
          })
          this.dialogVisible = false
          this.$refs[this.table.ref].getList()
        })
      })
    }
  }
}
</script>


<style>
.map {
  height: 300px;
}
</style>
